var businessManage = {};
businessManage.methods = {};

$(function(){

    // 商品管理列表
    businessManage.methods.dataGrid(); 

    // 分页
    var page = new Controller.PageControl();
    page.init({
        totalCount:20,    //总页数
        conter:".shop-page",    //容器选择器
        nowPage:1,        //当前页，默认第几页
        //callback:fun,       //点击回调
        // gotoCallBack:fun    //跳转回调
    });

})

// 商品管理列表
businessManage.methods.dataGrid = function (d) {


    //var d = [
    //    {OrderNumber:"7-309-045475343",WaresCount:"月亮与六便士（新版作家榜经",WaresQty:"35.60",CreatedTimeString:"北京工业出版社",ReceiverName:"否",BuyerNick:"上架" },
    //    {OrderNumber:"7-309-045475343",WaresCount:"月亮与六便士（新版作家榜经",WaresQty:"35.60",CreatedTimeString:"北京工业出版社",ReceiverName:"否",BuyerNick:"上架"},
    //    {OrderNumber:"7-309-045475343",WaresCount:"月亮与六便士（新版作家榜经",WaresQty:"35.60",CreatedTimeString:"北京工业出111社",ReceiverName:"是",BuyerNick:"下架"},
    //    {OrderNumber:"7-309-045475343",WaresCount:"月亮与六便士（新版作家榜经",WaresQty:"35.60",CreatedTimeString:"北京工业出版社",ReceiverName:"是",BuyerNick:"下架"},
    //    {OrderNumber:"7-309-045475343",WaresCount:"月亮与六便士（新版作家榜经",WaresQty:"35.60",CreatedTimeString:"北京工业出版社",ReceiverName:"是",BuyerNick:"下架"}
    //]
    d = JSON.stringify(d);
    console.log(d);

    Controller.GridControl.Bind(d, ".shop-manage-list-con", {

        BarCode: {
            cnName: "ISBN",
            index: 0,
            width:"136px",
            converter:ISBNConvert
        },
        Name: {
            cnName: "品名",
            index: 1,
            width:"166px",
            converter:pmConvert
        },
        CostPrice: {
            cnName: "定价",
            index: 2,
            width:"103px",
            converter:djpmConvert
        },
        Publisher: {
            cnName: "出版社",
            index: 3,
            width:"133px",
            converter:cbsConvert
        },
        StateName: {
            cnName: "是否在销",
            index: 4,
            width:"124px",
            converter:sfzxConvert
        },
        StateStr: {
            cnName: "操作",
            index: 5,
            width:"96px",
            converter:czConvert
        }

    },true,true); 
}


//转换器 
function ISBNConvert(val) {
    var _html =  '<span class="shop-manage-list-con-ISBN">'+val+
                    '<a href="javascript:void(0);" class="shop-manage-list-con-ISBN-imgBox" >\
                        <img class="shop-white-corner" src="../../images/static/shop_business_whiteCorner.png">\
                        <img class="shop-ISBN-img" src="../../images/upload/shop-you-may-also-like.img.png">\
                    </a>\
                </span>';
    return _html;
}
function pmConvert(val) {
    var _html =  '<span class="shop-manage-list-con-pm">'+ val +'</span>';
    return _html;
}
function djpmConvert(val) {
    var _html =  '<span class="shop-manage-list-con-dj">'+ val +'</span>';
    return _html;
}
function cbsConvert(val) {
    var _html =  '<span class="shop-manage-list-con-cbs">'+ val +'</span>';
    return _html;
}
function sfzxConvert(val) {
    if(val == "是"){
        return '<span class="shop-manage-list-con-sfzx">'+ val +'</span>';
    }else if(val == "否"){
        return '<span class="shop-manage-list-con-sfzx shop-sfzxs-no">'+ val +'</span>';
    }
    
}
function czConvert(val){
    var _html = '<span class="shop-manage-list-con-cz">'+ val +'</span>';
    return _html;
}




